<template>
	<!-- 大布局 -->
	<view class="layout">
		
		<view :class="['navbar', props.bgType]">
			<!-- 状态栏占位 -->
			<view class="status-bar" :style="{height:getStatusBarHeight() + 'px'}"> 
				<!-- i am status-bar -->
			</view>
			<view class="title-bar" :style="{ height: getTitleBarHeight() + 'px', marginLeft:getLeftIcon()+'px' }">
				<view class="backButton" v-if="showBackButton" @click="onClickBackButton"> <uni-icons type="left" size="20"></uni-icons> </view>
				<image class="logo" src="../../static/七彩童年_logo_5-removebg-preview.png" mode="aspectFit"></image>
				<view class="search" v-if="showSearchButton">
					<uni-icons class="icon" type="search" color="#888" size=20></uni-icons>
					<text class="text"> search </text>
				</view>
				<view class="title"> {{title}} </view>
			</view>
		</view>
		
	</view>
</template>

<script setup>
	import { computed, ref } from 'vue';
	import { SYSTEM_INFO, getStatusBarHeight, getTitleBarHeight, getNavBarHeight, getLeftIcon } from '@/utils/system.js';
	import { onLoad, onReady, onShow, onHide, onUnload, onPageScroll } from "@dcloudio/uni-app"

	const props = defineProps({
		title:{
			type: String,
			default:"默认标题"
		},
		bgType:{
			type: String,
			default: "OrangeFrostedGlass"
		},
		showBackButton:{
			type: Boolean,
			default: false
		},
		showSearchButton:{
			type: Boolean,
			default: false
		}
	})
	
	const bgTypeRef = ref();
	
	const onClickBackButton = ()=>{
		uni.navigateBack({
			animationType: 'pop-out',
			animationDuration: 200
		});
	}
	
	// console.log("in my-nav-bar: porps.bgtype:", props.bgType);
	onReady(()=>{
		bgTypeRef.value = props.bgType;
		// console.log("in my-nav-bar: porps.bgtype:", props.bgType);
		// console.log("in my-nav-bar: bgtype ref:", bgTypeRef.value);
	})
	

</script>

<style lang="scss" scoped>
	.colorful{
		background:
			linear-gradient(to bottom, transparent 0%, rgba(255, 255, 255, 0.5) 100vh),
			linear-gradient(to right, rgba(250, 150, 0, 0.8) 20%, rgba(255, 255, 255, 0.8));
		backdrop-filter: blur(10rpx);
	}
	.transparent{
		// background: transparent 0%;
		background: rgba(0,0,0,0);
	}
	.pureWhite{
		background: rgba(255,255,255,1);
		box-shadow: 0px -5px 15px 5px rgba(0, 0, 0, 0.55);
	}
	.pureYellow{
		background: rgba(255, 255, 15,1);
		box-shadow: 0px -5px 15px 5px rgba(0, 0, 0, 0.55);
	}
	.pureOrange{
		background: rgba(250, 150, 0, 0.8);
		box-shadow: 0px -5px 15px 5px rgba(0, 0, 0, 0.55);
	}
	.WhiteFrostedGlass{
		background: rgba(255,255,255,0.55);
		backdrop-filter: blur(5.5px);
		box-shadow: 5px 5px 5px 2px rgba(0, 0, 0, 0.2); /* 水平偏移量 垂直偏移量 模糊半径 阴影颜色 */
	}
	.OrangeFrostedGlass{
		background: rgba(250, 150, 0, 0.5);
		backdrop-filter: blur(5px);
		box-shadow: 5px 5px 5px 2px rgba(0, 0, 0, 0.2); /* 水平偏移量 垂直偏移量 模糊半径 阴影颜色 */
	}
	.PurpleFrostedGlass{
		background: rgba(216, 104, 180, 0.80);
		backdrop-filter: blur(5px);
		box-shadow: 5px 5px 5px 2px rgba(0, 0, 0, 0.2); /* 水平偏移量 垂直偏移量 模糊半径 阴影颜色 */
	}
	
	
	.layout{
		background: rgba(0,0,0,0);
		.navbar{
			position: fixed;
			top: 0;
			left: 0;
			width: 100%;
			z-index: 1919810;
			
			.status-bar{
				// border: 2px solid blue;
			}
			.title-bar{
				// border: 1px solid red;
				
				display: flex;
				align-items: center;
				padding: 0 20rpx;
				height: 100rpx;
				
				.title{
					// border: 1px solid red;
					font-size: 20px;
					font-weight: 500;
					color: #000;
					transform: translateY(-5rpx);
				}
				.logo{
					// border: 1px solid blue;
					// bottom: 10rpx;
					transform: translateY(-5rpx);
					left: 0;
					height: 80rpx;
					width: 240rpx;
				}
				.search{
					transform: translateY(-5rpx);
					width: 220rpx;
					height: 50rpx;
					border-radius: 60rpx;
					background: rgba(255,255,255,0.4);
					border: 1px solid #fff;
					margin-left: 30rpx;
					color: #888;
					font-size: 30rpx;
					display: flex;
					align-items: center;
					.icon{
						margin-left: 5rpx;
					}
					.text{
						padding-left: 10rpx;
					}
				}
				
			}
		}
	}
	
	.fill{
		// border: 1px solid red;
	}
</style>